package com.ndp.fb.enums.productfeed;

import lombok.Getter;

/**
 * feed创建中状态
 * 创建流程过长 ，记录创建中的状态。查库也就知道进行到哪个步骤出错 对应product_we_feed表operate_status
 * Created by Evan on 2016/4/20.
 */
@Getter
public enum FeedWeCreatingStatus {

    /**
     * 刚保存上product we feed表
     */
    FEEDWE_WAIT_SEND("feedwe_wait_send",0),

    /**
     * 多url merge 完成
     */
    FEEDWE_URL_MERGE_OK("url_merge_ok",1),
    FEEDWE_URL_MERGE_FAIL("url_merge_fail",2),

    /**
     * FEED XML 校验完成
     */
    FEEDWE_XML_CHECK_OK("xml_check_ok",3),
    FEEDWE_XML_CHECK_FAIL("xml_check_fail",4),

    /**
     * 发送catalog到fb成功
     */
    SEND_CATALOG_OK("send_catalog_ok", 5),
    SEND_CATALOG_FAIL("send_catalog_fail", 6),

    /**
     * 绑定catalog与像素事件成功
     */
    BIND_CATALOG_PIXEL_OK("bind_catalog_pixel_ok", 7),
    BIND_CATALOG_PIXEL_FAIL("bind_catalog_pixel_fail", 8),

    /**
     * 发送20个feed到fb成功
     */
    SEND_FBFEED_OK("send_fbfeed_ok", 9),
    SEND_FBFEED_FAIL("send_fbfeed_fail", 10),

    /**
     * 更新中
     */
    FEEDWE_UPDATING("updating", 11),

    /**
     * FEEDWE创建成功
     */
    FEEDWE_CREATE_OK("feedwe_create_ok", 12),

    /**
     * FEEDWE更新成功
     */
    FEEDWE_UPDATE_OK("feedwe_update_ok", 13),

    /**
     * FEEDWE创建成功
     */
    FEEDWE_RETRYING("retrying", 14),

    FEEDWE_IMGBUILDER_START("img_build_start", 15),
    FEEDWE_IMGBUILDER_END("img_build_end", 16),
    FEEDWE_IMGBUILDER_ERROR("img_build_error", 20),
    /**
     * 没有关联产品目录
     */
    UNBIND_CATALOG("unbind_catalog", 17),
    BIND_SUCCESS("bind_success", 18),

    /**
     * 没有产品上传
     */
    NO_PRODUCT("no_product", 19);

    /**
     *status
     */
    private String status;

    /**
     *code
     */
    private int code;

    FeedWeCreatingStatus(String status, int code) {
        this.status = status;
        this.code = code;
    }

    /**
     * 根据code获取FeedWeCreatingStatus
     * @param code code
     * @return Status
     */
    public static FeedWeCreatingStatus getStatus(int code) {
        for (FeedWeCreatingStatus c : FeedWeCreatingStatus.values()) {
            if (c.code == code) {
                return c;
            }
        }
        return null;
    }

    /**
     * 根据status获取FeedWeCreatingStatus
     * @param status status
     * @return Status
     */
    public static FeedWeCreatingStatus getStatus(String status) {
        for (FeedWeCreatingStatus c : FeedWeCreatingStatus.values()) {
            if (c.status.equals(status)) {
                return c;
            }
        }
        return null;
    }
}
